package com.dhnsoft.boot.features;

import com.dhnsoft.boot.features.bean.Cat;
import com.dhnsoft.boot.features.bean.Dog;
import com.dhnsoft.boot.features.bean.Pig;
import com.dhnsoft.boot.features.bean.Sheep;
import com.dhnsoft.boot3.starter.RobotAutoConfiguration;
import com.dhnsoft.boot3.starter.robot.annotation.EnableRobot;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;

import javax.swing.*;

@SpringBootApplication
@Slf4j
//@Import(RobotAutoConfiguration.class)

public class Boot306FeaturesApplication {

	public static void main(String[] args) {
		//1.SpringApplication:Boot应用的核心API入口
//		SpringApplication.run(Boot306FeaturesApplication.class, args);

		//将如上的代码分解
		//1.自定义SpringApplication的底层设置
//		SpringApplication application = new SpringApplication();

		//调整springApplication的参数
//		application.setDefaultProperties();
		//这个配置不优先
//		application.setBannerMode(Banner.Mode.CONSOLE);

		//配置文件优先级高于程序化调整的优先级

		//2.SpringApplication运行起来
//		application.run();

		ConfigurableApplicationContext context = new SpringApplicationBuilder()
				.main(Boot306FeaturesApplication.class) //各种参数均可设置
				.sources(Boot306FeaturesApplication.class)
				.bannerMode(Banner.Mode.CONSOLE)
				.properties("server.port=8888","aaa=bbb") //springboot所有配置项都可以在这里定义
//                .environment(null)
//                .listeners(null)
				.run(args);

		try {
			Cat cat = context.getBean(Cat.class);
			log.info("组件cat：{}",cat);
		}catch (Exception e){

		}

		try {
			Dog dog = context.getBean(Dog.class);
			log.info("组件dog：{}",dog);
		}catch (Exception e){

		}

		try {
			Pig pig = context.getBean(Pig.class);
			log.info("组件pig：{}",pig);
		}catch (Exception e){

		}

		try {
			Sheep sheep = context.getBean(Sheep.class);
			log.info("组件sheep ：{}",sheep);
		}catch (Exception e){

		}
		}

}
